import React, { Suspense } from 'react';
import { BrowserRouter, Route, Switch, HashRouter } from 'react-router-dom';
import routes from './routes.js'


const renderRouter = routers =>
  routers.map(el => <Route key={el.path} path={el.path} component={el.component} />)

const Router = () => {
  return (
    <BrowserRouter>
      <Suspense fallback={<div></div>}>
        <Switch>
          {renderRouter(routes)}
        </Switch>
      </Suspense>
    </BrowserRouter>
  );
};

export default Router;